//
//  UIBarButtonItem+extension.m
//  MySinaWeiboProjectForOC
//
//  Created by apple on 2016/11/13.
//  Copyright © 2016年 WangChen. All rights reserved.
//

#import "UIBarButtonItem+extension.h"

@implementation UIBarButtonItem (extension)

-(instancetype)initWithTitle:(NSString *)title image:(NSString *)imageName addTarget:(id)target action:(SEL)action{
    
    if(self = [self init]){
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] forState:UIControlStateHighlighted];
        
        [btn setTitle:title forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
        
        btn.titleLabel.font = [UIFont systemFontOfSize:20];
        [btn sizeToFit];
        
        [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        
        self.customView = btn;
        
    }
    return self;
}


@end
